package org.mspring.mlog.duoshuo.service;

import org.mspring.mlog.duoshuo.dao.DuoshuoSyncLogDao;
import org.mspring.mlog.duoshuo.entity.DuoshuoSyncLog;
import org.mspring.nbee.common.PageResult;
import org.mspring.nbee.db.dao.sql.builder.part.condition.SqlCondition;
import org.mspring.nbee.db.dao.sql.pager.SqlPager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Gao Youbo
 * @since 2015-02-19 13:02:58
 */
@Service
public class DuoshuoSyncLogService {

    private static final Logger LOG = LoggerFactory.getLogger(DuoshuoSyncLogService.class);

    private DuoshuoSyncLogDao duoshuoSyncLogDao;

    public DuoshuoSyncLog findById(long id) {
        return duoshuoSyncLogDao.findById(id);
    }

    public PageResult<DuoshuoSyncLog> list(List<SqlCondition> conditions, SqlPager pager) {
        return duoshuoSyncLogDao.listPage(conditions, pager);
    }

    /**
     * 获取最后的log_id
     *
     * @return
     */
    public long findLastLogId() {
        return duoshuoSyncLogDao.findLastLogId();
    }

    @Transactional
    public boolean insert(DuoshuoSyncLog duoshuoSyncLog) {
        return duoshuoSyncLogDao.insert(duoshuoSyncLog);
    }

    @Transactional
    public boolean update(DuoshuoSyncLog duoshuoSyncLog) {
        return duoshuoSyncLogDao.update(duoshuoSyncLog);
    }

    @Transactional
    public boolean deleteById(long id) {
        return duoshuoSyncLogDao.deleteById(id);
    }

    @Autowired
    public void setDuoshuoSyncLogDao(DuoshuoSyncLogDao duoshuoSyncLogDao) {
        this.duoshuoSyncLogDao = duoshuoSyncLogDao;
    }

}